<template>
    <el-tab-pane :label="inorout === 2 ? '合同回款' : '合同付款'" name="fund" v-if="inorout !== 1">
        <z-table :title="inorout === 2 ? '回款计划' : '付款计划'" url="/do/select/plan"
                 :params="params"
                 :columns="planColumns" :size="5">
            <template #header$="">
                <z-action label='添加计划' mode='dialog' :data="params" :fields="planFields"
                          type='primary'
                          url='/do/put/plan'/>
            </template>
            <template #action$="{ row }">
                <z-action label='编辑' mode='dialog' :fields=planFields link :data="row" url='/do/patch/plan'
                          includeTitle='r'/>
            </template>
        </z-table>
        <div class="spacing"></div>
        <z-table :title="inorout === 2 ? '回款记录' : '付款记录'" url="/do/select/funds_perform"
                 :params="relatedParams" :columns="fundColumns" :size="5">
            <template #header$="">
                <z-action :label="inorout === 2 ? '添加回款' : '添加付款'" mode='dialog'
                          :fields="fundFields"
                          type='primary' url='/api/funds/addFund'/>
            </template>
            <template #action$="{ row }">
                <z-action label='详情' :data="row" mode='dialog' href='/finance/fundDetail' width='1000px' link
                          :map="{ id: 'id' }"/>
                <z-action v-if="row.status === 2" label='核销' mode='confirm' link :data="row"
                          url='/api/funds/verification'/>
            </template>
        </z-table>
    </el-tab-pane>
</template>

<script>


export default {
    props: {
        params: Object,
        inorout: Object,
    },
    data() {
        return {
            relatedParams: null,
            planColumns: [
                {label: "期次", name: "period"},
                {label: "日期", name: "date", type: "date"},
                {label: "金额", name: "amount", type: "money"},
                {label: "类型", name: "planType", code: "cfg_fundsPlan"}
            ],
            planFields: [
                {label: "期次", name: "period"},
                {label: "日期", name: "date", type: "date"},
                {label: "金额", name: "amount", type: "money"},
                {label: "类型", name: "planType", code: "cfg_fundsPlan"},
                {label: "备注", name: "extra"},
                {
                    label: "关联合同",
                    name: "contractId",
                    default: this.params.contractId,
                    visible: true
                },
                {
                    label: "分类",
                    name: "type",
                    default: this.inorout,
                    code: "fundType",
                    visible: true
                }
            ],
            fundColumns: [
                {label: "金额", name: "amount", type: "money"},
                {label: "日期", name: "date", type: "date"},
                {label: "账户", name: "account", depend: "account"},
                {label: "单据编号", name: "document"},
                {label: "创建人", name: "creator", type: "user"},
                {label: "核销人", name: "verificationEmp", type: "user"},
                {label: "状态", name: "status", code: "fundStatus"},
            ],
            fundFields: [
                {
                    label: "账款类型",
                    name: "type",
                    code: "fundType",
                    default: this.inorout,
                    readonly: true,
                    required: true
                },
                {label: "关联合同", name: "related", default: this.params.contractId, visible: true},
                {
                    label: "核销方式",
                    name: "verificationMethod",
                    code: "verificationMethod",
                    default: 1,
                    required: true,
                    visible: this.inorout === 2
                },
                {label: "履约对象", name: "performParty", required: true},
                {label: "账户", name: "account", type: "search", depend: "account", required: true},
                {label: "日期", name: "date", type: "date", required: true},
                {label: "金额", name: "amount", required: true, type: "money"},
                {label: "单据编号", name: "document"},
                {label: "备注", name: "extra"},
                {
                    label: "核销员工",
                    type: "user",
                    name: "verificationEmp",
                    required: true,
                    visible: this.inorout === 2
                },
                {label: "附件", name: "attachment"}
            ],
        }
    },
    created() {
        this.relatedParams = {related: this.params.contractId}
    },
    methods: {}
}
</script>
<style scoped>

.spacing {
    margin: 100px 0;
    height: 0;
    position: relative;
}
</style>

